---

# postgres

postgres_vendor: "postgresql"
postgres_edition: "std"
postgres_cluster_type: "native"

postgres_version: "{{ postgres_version_dict[postgres_vendor][postgres_os_family] }}"
postgres_bin: "{{ postgres_dict.postgres_bin }}"
postgres_packages: "{{ postgres_dict.postgres_packages }}"
postgres_packages_ext: "{{ postgres_dict.postgres_packages_ext }}"
postgres_home: "{{ postgres_dict.postgres_home }}"
postgres_service: "{{ postgres_dict.postgres_service }}"
postgres_service_source: "{{ postgres_dict.postgres_service_source }}"
postgres_service_default: "{{ postgres_dict.postgres_service_default }}"
postgres_service_enabled: "{{ postgres_cluster_dict[postgres_cluster_type].postgres_service_enabled }}"
postgres_data: "{{ postgres_dict.postgres_data }}"
postgres_conf: "{{ postgres_dict.postgres_conf }}"
postgres_log: "{{ postgres_dict.postgres_log }}"

# postgres conf

postgres_superuser: "postgres"
postgres_replication: "replication"
postgres_replication_password: "replication11password"
postgres_backup: "backup"
postgres_backup_password: "backup11password"

postgres_default_vars: "{{ postgres_dict.postgres_default_vars }}"
postgres_user_vars:
  - name: "PATH"
    value: "$PATH:~/dba/scripts"

postgres_config_source: "postgresql.conf-{{ postgres_version }}.j2"
postgres_hba_source: "pg_hba.conf.j2"
postgres_ident_source: "pg_ident.conf.j2"

postgres_port: "5432"
postgres_config:
  max_connections: "100"
postgres_hba_config:
  - type: "host"
    database: "all"
    user: "all"
    address: "0.0.0.0/0"
    method: "md5"
postgres_ident_config: []
  #- mapname: "maproot"
  #  system_username: "root"
  #  pg_username: "postgres"
postgres_cluster_hosts: []
postgres_backup_hosts: []

# postgres initdb

postgres_initdb_hostname: "{{ inventory_hostname }}"
postgres_initdb_ip: "{{ (postgres_cluster_hosts | items2dict(key_name='host', value_name='ip'))[postgres_initdb_hostname] }}"
postgres_initdb_primary: "{{ postgres_bin }}/initdb --pgdata={{ postgres_data }} --locale=ru_RU.UTF-8 --encoding=UTF-8 --data-checksums"
postgres_initdb_standby: "{{ postgres_bin }}/pg_basebackup -h {{ postgres_initdb_ip }} -p {{ postgres_port }} -U {{ postgres_replication }} -R -X stream -w -D {{ postgres_data }}"

# postgres install options

postgres_packages_enabled: True
postgres_user_enabled: True
postgres_initdb_enabled: True
